package com.fluxtah.jordl.examples.twitter;

import com.fluxtah.jordl.lib.TransformerProvider;
import com.fluxtah.jordl.lib.TransformException;
import com.fluxtah.jordl.lib.HttpRequestHelper;
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;

public class TwitterClient {
	
	private static final String DEFAULT_BASE_URL = "http://api.twitter.com/1";
	
	protected final HttpRequestHelper requestHelper;
	private final TransformerProvider transformerProvider;
	private final String baseUrl;

	public TwitterClient(HttpRequestHelper requestHelper){
		this(requestHelper, new TransformerProvider(), DEFAULT_BASE_URL);
	}

	public TwitterClient(HttpRequestHelper requestHelper, TransformerProvider transformerProvider){
		this(requestHelper, transformerProvider, DEFAULT_BASE_URL);
	}

	public TwitterClient(HttpRequestHelper requestHelper, TransformerProvider transformerProvider, String baseUrl){
		this.requestHelper = requestHelper;
		this.baseUrl = baseUrl;
		this.transformerProvider = transformerProvider;
	}
	
	public GetStatusResponse getStatus(GetStatusRequest request)
	  throws ClientProtocolException, IOException, TransformException {			
		return request.createResponse(baseUrl, requestHelper, transformerProvider);
	}
	public SetStatusResponse setStatus(SetStatusRequest request)
	  throws ClientProtocolException, IOException, TransformException {			
		return request.createResponse(baseUrl, requestHelper, transformerProvider);
	}
}
